﻿/**
 *
 * hw.h
 *
 *  Created on: 2018-05-11
 *      Author: chenshisheng
 */

#ifndef HW_H_
#define HW_H_

#include "main.h"
#include "stream/stream.h"
#include "message_queue.h"

typedef enum
{
    HW_Level_Low = RESET,
    HW_Level_High = SET
}HW_Level_t;

typedef enum
{
    HW_State_Inactive = DISABLE,
    HW_State_Active =  ENABLE
}HW_State_t;

typedef enum
{
    HW_In_IrIn,
    HW_In_LockIn1,
    HW_In_LockIn2,
}HW_In_t;

typedef enum
{
    HW_Out_Run,
    HW_Out_NetEn,
    HW_Out_NetRst,
    HW_Out_LoadEn,
    HW_Out_SpeakerEn,
    HW_Out_IrEn,
    HW_Out_Lock1,
}HW_Out_t;

typedef enum
{
    HW_Exti_User,
    HW_Exti_Deliver1,
    HW_Exti_Deliver2,
    HW_Exti_LockIn1,
    HW_Exti_LockIn2,
}HW_Exti_t;

typedef void (*HW_ExtiCallback_t)(int data);

void HW_Init(void);
void HW_SetExtiCallback(HW_Exti_t exti, HW_ExtiCallback_t cb, int data);
void HW_ExtiCmd(HW_Exti_t exti, FunctionalState state);
void HW_OnExtiMsg(MsgQueue_Msg_t *msg);

void HW_Set(HW_Out_t out, HW_Level_t level);
HW_Level_t HW_GetSetted(HW_Out_t out);
void HW_Config(HW_Out_t out, HW_State_t status);
HW_State_t HW_IsConfigedActive(HW_Out_t out);
void HW_Toggle(HW_Out_t out);

HW_Level_t HW_Get(HW_In_t in);
bool HW_IsActive(HW_In_t in);
bool HW_IsExtiActive(HW_Exti_t exti);

unsigned int HW_ReadBoardAddres(void);
int HW_IoInCmd(Stream_t *stream, int argc, char *argv[]);
int HW_IoOutCmd(Stream_t *stream, int argc, char *argv[]);
//void HW_OnExtiMsg(MsgQueue_Msg_t *msg);

#endif /* HW_H_ */
